package pe.com.bbva.ge.domain.base;

import javax.persistence.MappedSuperclass;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

@MappedSuperclass
public abstract class Identificador extends Auditoria implements Comparable<Identificador> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2141788688877554268L;
	
	protected String codigo;
	
	public String getCodigo() {
		return this.codigo;
	}

	public void setCodigo(String codigo) {
		this.codigo = codigo;
	}

	@Override
	public int hashCode() {
		HashCodeBuilder hashCodeBuilder = new HashCodeBuilder(31, 7);
		hashCodeBuilder.append(codigo);
		return hashCodeBuilder.toHashCode();
	}

	@Override
	public boolean equals(Object obj) {
		boolean equals = false;
		if (obj instanceof Identificador){
			Identificador bean = (Identificador) obj;
			EqualsBuilder equalsBuilder = new EqualsBuilder();
			equalsBuilder.append(codigo, bean.codigo);
			equals = equalsBuilder.isEquals();
		}
		return equals;
	}
	
	@Override
	public int compareTo(Identificador o) {
		return this.codigo.compareTo(o.codigo);
	}

}
